#import "BaseSearchViewController.h"
@interface BaseSearchViewController ()
@end
@implementation BaseSearchViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    self.isHidenNaviBar = YES;
    [self setNavigationBar];
    [self setBaseInfo];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
-(void)setBaseInfo{
    self.tableView.frame = CGRectMake(0, kTopHeight, SCREEN_WIDTH, SCREEN_HEIGHT - kTopHeight);
    self.tableView.showsVerticalScrollIndicator = NO;
    self.tableView.mj_footer.hidden = YES;
    self.tableView.mj_header.hidden = YES;
    [self.view addSubview:self.tableView];
}
-(void)setNavigationBar{
    self.title = nil;
    [self setSearchBar];
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.view endEditing:YES];
}
#pragma mark - 定制界面
-(void)setSearchBar{
    UIView* bgView = [[UIView alloc] init];
    bgView.backgroundColor = [UIColor qmui_colorWithHexString:@"#f2f2f2"];
    bgView.layer.cornerRadius = 17.f;
    bgView.layer.masksToBounds = YES;
    bgView.layer.borderColor = [UIColor qmui_colorWithHexString:@"dbdbdb"].CGColor;
    bgView.layer.borderWidth = 1;
    [self.view addSubview:bgView];
    [bgView addSubview:self.searchText];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(kStatusBarHeight + 5);
        make.left.equalTo(self.view).offset(9);
        make.height.mas_equalTo(34);
        make.width.mas_equalTo(SCREEN_WIDTH - 63 - 9);
    }];
    [self.view addSubview:self.searchBtn];
    [self.searchText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.right.equalTo(bgView);
    }];
    [self.searchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(bgView);
        make.right.equalTo(self.view).offset(-14);
    }];
    @weakify(self);
    [self.searchBtn addTapBlock:^(UIButton *btn) {
        [weak_self.navigationController popViewControllerAnimated:YES];
    }];
}
-(UIButton *)searchBtn{
    if (!_searchBtn) {
        _searchBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_searchBtn setTitle:ASLocalizedString(@"取消")forState:UIControlStateNormal];
        _searchBtn.titleLabel.font = [UIFont systemFontOfSize:18];
        [_searchBtn setTitleColor:kBlackColor forState:UIControlStateNormal];
    }
    return _searchBtn;
}
-(SearchTextField *)searchText{
    if (!_searchText) {
        _searchText = [[SearchTextField alloc] init];
        _searchText.placeholder = ASLocalizedString(@"请输入用户名");
        [_searchText setValue:[UIColor qmui_colorWithHexString:@"D1D1D5"] forKeyPath:@"_placeholderLabel.textColor"];
        [_searchText setValue:[UIFont systemFontOfSize:12] forKeyPath:@"_placeholderLabel.font"];
        _searchText.font = [UIFont systemFontOfSize:13];
        _searchText.textColor = KBlackColor;
        _searchText.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        [_searchText setBorderStyle:UITextBorderStyleNone];
        _searchText.backgroundColor = [UIColor qmui_colorWithHexString:@"F3F3F3"];
        _searchText.autocorrectionType = UITextAutocorrectionTypeNo;
        _searchText.returnKeyType = UIReturnKeySearch;
        _searchText.tintColor = KBlackColor;
        _searchText.clearButtonMode = UITextFieldViewModeWhileEditing;
        _searchText.delegate = self;
        [_searchText becomeFirstResponder];
        [_searchText addTarget:self action:@selector(textFieldEditChanged:) forControlEvents:UIControlEventEditingChanged];
    }
    return _searchText;
}
-(void)nextStep{
    [self.searchText resignFirstResponder];
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)textFieldEditChanged:(UITextField *)textField{
}
@end
